from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.viewsets import ModelViewSet
from meiduo_admin.utils import PageNum
from meiduo_admin.serializers.permission import PermissionSerialzier, ContentTypeSerialzier

# 获取用户权限表列表数据
# 修改权限表
# 删除权限表数据
class PermissionView(ModelViewSet):
    serializer_class = PermissionSerialzier
    queryset = Permission.objects.all().order_by('id')
    pagination_class = PageNum

# 保存权限表数据
# 获取权限类型列表数据
# 获取修改权限表的详情信息
class ContentTypeAPIView(APIView):

    def get(self,request):
        # 查询全选分类
        content = ContentType.objects.all()
        # 返回结果
        ser = ContentTypeSerialzier(content, many=True)

        return Response(ser.data)

